﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GridView.ascx.cs" Inherits="TaobaoERP.Views.Shared.GridView" %>
<%@ Import Namespace="System.Reflection" %>

<table width="100%" class="listview" cellpadding="3" cellspacing="1">
    <tbody>
        <tr>
            <% foreach (PropertyInfo prop in this.Columns){ %>
        <th><%= prop.Name %></th>   
        <% } %>

        </tr>
        <% foreach (object row in this.Rows)
           { %>
        <tr>
           <% foreach (PropertyInfo prop in this.Columns)
              { %>
            <td>
            <% var typeCode = Type.GetTypeCode(prop.PropertyType); %>
   
   
            <%-- String Columns --%>
            <% if (typeCode == TypeCode.String)
               { %>
               
                <%= GetColumnValue(row, prop.Name)%>
            
            <% } %>
   
            <%-- DateTime Columns --%>
            <% if (typeCode == TypeCode.DateTime)
               { %>
                
                <%= GetColumnValue(row, prop.Name, "{0:D}")%>
            
            <% } %>
   
   
            <%-- Decimal Columns --%>
            <% if (typeCode == TypeCode.Decimal)
               { %>
                
                <%= GetColumnValue(row, prop.Name, "{0:c}")%>
            
            <% } %>
   
   
            <%-- Boolean Columns --%>
            <% if (typeCode == TypeCode.Boolean)
               { %>
                <% if ((bool)(this.GetColumnValue(row, prop.Name)))
                   { %>
                   <input type="checkbox" disabled="disabled" checked="checked" />                   
                   <% }
                   else
                   { %>
                   <input type="checkbox" disabled="disabled" />
                <% } %>
            <% } %>
            
            
            <%-- Integer Columns --%>
            <% if (typeCode == TypeCode.Int32)
               { %>
                
                <%= GetColumnValue(row, prop.Name)%>
            
            <% } %>
            
            </td>
       <% } %>

        </tr>
        <%} %>
    </tbody>
</table>
